Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

themes.js hopefully last time #2133

Merged
merged 2 commits into from
Mar 30, 2024
Merged

themes.js hopefully last time #2133

merged 2 commits into from
Mar 30, 2024

Conversation

raszpl
Copy link
Contributor

@raszpl raszpl commented Mar 30, 2024

continuation #2076
Video description has some hardcoded text color, remove it make sure we remove cookie instead of writing 0

raszpl added 2 commits March 30, 2024 14:51
continuation #2076
Video description has some hardcoded text color, remove it
make sure we remove cookie instead of writing 0
Fixing YT hardcoded CSS for DARK/light mode switching
@ImprovedTube ImprovedTube merged commit 64f89e5 into code-charity:master Mar 30, 2024
@raszpl raszpl deleted the patch-1 branch March 30, 2024 15:59
@ImprovedTube
Copy link
Member

hi! @raszpl thanks!!

btw, is it the current version what makes youtube's home page empty?
running the themes function can be conditional on it being set intentionally

case 'default':
case 'dawn':
case 'sunset':
case 'night':
case 'plain':
case 'desert':
document.documentElement.removeAttribute('dark');
document.querySelector('ytd-masthead')?.removeAttribute('dark');
document.querySelector('ytd-masthead')?.removeAttribute('style');
document.getElementById('cinematics')?.removeAttribute('style');
this.elements.my_colors?.remove();
break
}
let cookie = this.getPrefCookieValueByName('f6');
// f6 stores more than Theme. Treat it like hex number, we are only allowed to add/remove 0x80000 (light theme) and 0x400 (dark theme).
if (cookie && !isNaN(cookie)) {
// valid f6
let negation = parseInt(cookie, 16) & parseInt(80400, 16);
cookie = (parseInt(cookie, 16) - negation); // remove 80000 and 400
cookie = cookie ^ (darkCookie ? parseInt(400, 16) : 0); // apply optional darkCookie
cookie = cookie.toString(16); // back to hex
} else {
// missing or corrupted f6, fully overwrite
cookie = darkCookie ? 400 : null;
}
this.setPrefCookieValueByName('f6', cookie);
};

we might only need to adjust the cookie the exact same moment when the user does so by shortcut.
or when storage changes to or from themes:"youtube's dark mode"

@raszpl
Copy link
Contributor Author

raszpl commented Mar 30, 2024

btw, is it the current version what makes youtube's home page empty?

both straight homepage and redirect work fine for me

running the themes function can be conditional on it being set intentionally

only on startup (added #2134), otherwise you break dynamic theme switching.

we might only need to adjust the cookie the exact same moment when the user does so by shortcut.
or when storage changes to or from themes:"youtube's dark mode"

its already there, setPrefCookieValueByName only writes cookie if new value is different
some more changes #2134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants